﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Limestone.MVC
{
    public static class ExtensionMethods
    {
        public static IPage ToIPage(this EditedPage p)
        {
            return new Page
            {
                Created = p.Created,
                Deleted = p.Deleted,
                Hidden = p.Hidden,
                CreatedBy = p.CreatedBy,
                DeletedBy = p.DeletedBy,
                Fields = p.Fields,
                Modified = p.Modified,
                ModifiedBy = p.ModifiedBy,
                Name = p.Name,
                Path = p.Path,
                SortChildPagesBy = p.SortChildPagesBy,
                SortValue = p.SortValue,
                TemplatePath = p.TemplatePath,
                Title = p.Title
            };
        }
        public static EditedPage ToEditedPage(this IPage p)
        {
            return new EditedPage
            {
                Created = p.Created,
                Deleted = p.Deleted,
                Hidden = p.Hidden,
                CreatedBy = p.CreatedBy,
                DeletedBy = p.DeletedBy,
                Fields = p.Fields,
                Modified = p.Modified,
                ModifiedBy = p.ModifiedBy,
                Name = p.Name,
                Path = p.Path,
                SortChildPagesBy = p.SortChildPagesBy,
                SortValue = p.SortValue,
                TemplatePath = p.TemplatePath,
                Title = p.Title,

                OriginalName = p.Name
            };
        }

        public static DesignedTemplate ToDesignedTemplate(this IPageTemplate template)
        {
            return new DesignedTemplate
            {
                Name = template.Name,
                HelpText = template.HelpText,
                Path = template.Path,
                FieldSettings = template.FieldSettings
            };
        }
        public static IPageTemplate ToIPageTemplate(this DesignedTemplate template)
        {
            return new PageTemplate
            {
                Name = template.Name,
                HelpText = template.HelpText,
                Path = template.Path,
                FieldSettings = template.FieldSettings
            };
        }
    }
}
